package site.shader85.Kingdoms;

import org.bukkit.configuration.serialization.ConfigurationSerialization;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;

import site.shader85.Kingdoms.domain.Domain;
import site.shader85.Kingdoms.domain.DomainConfig;
import site.shader85.Kingdoms.domain.Manor;
import site.shader85.Kingdoms.domain.area.Area;
import site.shader85.Kingdoms.domain.area.Position;
import site.shader85.Kingdoms.inventory.GUIListener;
import site.shader85.Kingdoms.war.KingdomWarManager;
import site.shader85.Kingdoms.war.WarConfig;

public class KingdomsPlugin extends JavaPlugin {

	private DomainConfig domainConfig;
	private WarConfig warConfig;
	private KingdomWarManager warManager;
	private static KingdomsPlugin instance;
	
	static {
		ConfigurationSerialization.registerClass(Position.class, "Position");
		ConfigurationSerialization.registerClass(Domain.class, "Domain");
		ConfigurationSerialization.registerClass(Manor.class, "Manor");
		ConfigurationSerialization.registerClass(Area.class, "Area");
	}

	@Override
	public void onEnable() {
		instance = this;
		loadConfig();
		loadManager();
		loadListener();
	}

	public void loadConfig() {
		domainConfig = new DomainConfig(this);
		warConfig = new WarConfig(this);
	}

	public void loadManager(){
		warManager = KingdomWarManager.execute(this);
	}
	
	public void loadListener(){
		PluginManager pm = getServer().getPluginManager();
		pm.registerEvents(new GUIListener(), this);
	}
	
	public DomainConfig getDomainConfig() {
		return domainConfig;
	}

	public WarConfig getWarConfig() {
		return warConfig;
	}
	
	public static KingdomsPlugin getInstance(){
		return instance;
	}
}
